﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Data.SqlTypes;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;



namespace LogosoftSharepoint
{
    public class DBHandler
    {
        DBHandler() { }

        public static String simpleQuery()
        {
            SqlCommand cmd;
            SqlConnection cn;
            SqlDataReader rdr;
            String result = "";

            cn = new SqlConnection(ConfigurationManager.ConnectionStrings["MySqlConnection"].ConnectionString);
            try
            {
                cn.Open();
                cmd = new SqlCommand("SELECT * FROM person",cn);
                //cmd.ExecuteNonQuery();   //number of rows
                rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    //poki co wypisuje tylko imie i nazwisko
                    result += rdr.GetString(1);
                    result += rdr.GetString(2);
                }
            }
            catch (SqlException ex)
            {
                return "mamy bledy";
            }
            return result;

        }
    }
}
